﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ext.Net;

namespace Sio.Mdm.Web
{
	public partial class Header : Controls.UserControl
	{
		protected void Page_Load(object sender, System.EventArgs e)
		{
			 if (!IsPostBack && !X.IsAjaxRequest)
			{
                if (UserSession != null)
                    this.Prijavljen.Text = String.Format("Prijavljen: {0} {1}@{2}", UserSession.Ime, UserSession.Priimek, UserSession.OrganizacijaNaziv);
                else
                {
                    FormsAuthentication.RedirectToLoginPage();
                    this.Prijavljen.Text = "Prijavljen: <napaka_v_sessionu>";
                }
			}
		}

		[DirectMethod]
		public void LogoutClick()
		{   
			FormsAuthentication.SignOut();
            // This will explicitly call Application.Session_End where call to BL Logout is made
            Session.Abandon();
			//ExtNet.Redirect(FormsAuthentication.LoginUrl, "preusmerjam");
		}
	}
}